package com.atguigu.dailyservice.schedule;
import cn.hutool.core.date.DateUtil;
import com.atguigu.dailyservice.service.StatisticsDailyService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
@Component
public class ScheduledTask {
	@Resource
	private StatisticsDailyService dailyService;

	/**
	 * 测试
	 * 每天七点到二十三点每五秒执行一次
	 */
	@Scheduled(cron = "0/5 * * * * ?")
	public void task1() {
		System.out.println("*********++++++++++++*****执行了");
	}

	/**
	 * 每天凌晨1点执行定时->统计今天注册了多少用户
	 */
	@Scheduled(cron = "0 0 1 * * ?")
	public void HandlerRegisterTask(){
		//获取上一天的日期
		String yesterday = DateUtil.yesterday().toDateStr();
		dailyService.createStatisticsByDay(yesterday);
		int localDate = LocalDate.now().getDayOfYear();

	}

}
